#version 140

in vec3 		in_Vertex;
in vec3 		in_Color;
in vec3			in_Normal;
in vec3			in_Texture;

uniform mat4	UniMatModelview;
uniform mat4	UniMatProjection;
uniform mat3	UniMatNormal;
uniform mat4	UniRotation;

uniform vec3	UniLightPosition;
uniform vec3	UniEyePosition;

smooth out vec3 out_VertexNormal;
smooth out vec3 out_LightDir;

void	main()
{
	mat3	matNormal = transpose(inverse(UniMatNormal));
	out_VertexNormal = normalize(matNormal * in_Normal);

	vec4	vertexPos4 = UniMatProjection * UniMatModelview * UniRotation * vec4(in_Vertex, 1.0);
	vec3	vertexPos = vertexPos4.xyz / vertexPos4.w;

	vec4	lightPos4 = UniMatModelview * vec4(UniLightPosition, 1.0);
	vec3	lightPos = lightPos4.xyz / lightPos4.w;

	out_LightDir = normalize(vertexPos - lightPos);
	gl_Position = vertexPos4;
}